<div class="row">
	<div class="overview four columns panel">
        <div class="dashboard-heading"><h3>Resumen</h3></div>
        <div class="dashboard-content">
          <table>
            <tbody><tr>
              <td>Total ventas:</td>
              <td>$ <?=$this->montoTotalPedidos ?></td>
            </tr>
            <tr>
              <td>Total ventas este año:</td>
              <td>$ <?=$this->montoTotalPedidosAnio ?></td>
            </tr>
            <tr>
              <td>Total pedidos:</td>
              <td><?=$this->totalPedidos ?></td>
            </tr>
            <tr>
              <td>No. de clientes:</td>
              <td><?=$this->totalClientes ?></td>
            </tr>
          </tbody></table>
        </div>
    </div>
	
	<div class="eight columns panel">
		<h3>Estadísticas</h3>
		<div id="chart_div" style="height: 188px;text-align:center;">
			<img src="<?php echo $this->baseUrl("/images/preload.gif");?>" alt="Cargando..." />
		</div>
	</div>
</div>
<div class="row">
	<div class="panel">
		
		<div class="latest">
        <div class="dashboard-heading"><h3>Pedidos Pendientes</h3></div>
        <div class="dashboard-content">
         <?php 
			echo $this->paginationControl($this->paginator, 'Sliding', 'templates/pagination.phtml');
			?>
			<?php if(count($this->paginator)==0) { ?>
				<p>No hay resultados disponibles.</p>
			<?php } else { ?>
				<table border="1">
				<thead>
					<tr>
					  <th>ID</th>
					  <th>Cliente</th>	  	  
					  <th>Telefono</th>	  	  
					  <th>Fecha</th>	  	  
					  <th>Total</th>	  	  
					  <th>Estado</th>	  	  
					  <th>Opciones</th>	  
					</tr>
				</thead>
				<tbody>
				<?php 
				 foreach($this->paginator as $record){ ?>
					<tr>
					  <td><?=$record['id_pedido']?></td>	
					  <td><?=$record['nombre']?> <?=$record['apellido']?></td>
					  <td><?=$record['telefono']?></td>						  
					  <td><?=$record['fecha_compra']?></td>						  
					  <td><?=$record['monto_total']?></td>						  
					  <td><?=$record['estado']?></td>						  
					  <td>
						<a href="<?php echo $this->baseUrl("/admin/pedidoseditar/id/".$record['id_pedido']); ?>">Editar Estado</a>
					  </td>	  
					</tr>
					
				<? } ?>
				</tbody>
				</table>
			<?php }?>
        </div>
      </div>
		
		
    </div>
</div>

<!-- Diagrama -->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
  google.load("visualization", "1", {packages:["corechart"]});
  google.setOnLoadCallback(drawChart);
  function drawChart() {
	var data = google.visualization.arrayToDataTable([
	  ['Mes', 'Monto Acumulado $'],
	  // ['2004',  1000],
	  // ['2005',  11700],
	  // ['2006',  660],
	  // ['2007',  1030]
	  <?php $datos = json_encode($this->statPedidosVentas);
		$datos = str_replace("{","[",$datos);
		$datos = str_replace("}","]",$datos);
		$datos = str_replace(",","],[",$datos);
		$datos = str_replace(":",",",$datos);
		echo $datos;
	  ?>
	]);

	var options = {
	  title: 'Gráfico: Montos Acumulados Mensuales de Pedidos',
	  hAxis: {title: 'Meses del Año <?php echo date("Y");?>',  titleTextStyle: {color: 'black'}}
	};

	var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
	chart.draw(data, options);
  }
</script>

